package com.lzl.service;

import com.lzl.dto.PassengerUser;
import com.lzl.dto.TokenResult;
import com.lzl.remote.ServicePassengerUserClient;
import com.lzl.responese.ResponseResult;
import com.lzl.util.JWTUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;

/**
 * //TODO
 *
 * @author zhaolinlin
 * @description //TODO
 * @createTime 2022/8/13 20:50
 */
@Service
@Slf4j
public class UserService {

    @Autowired
    ServicePassengerUserClient servicePassengerUserClient;

    public ResponseResult getUserByAccessToken(String accessToken) {
        log.info("accessToken信息:"+accessToken);
        TokenResult tokenResult = JWTUtils.checkToken(accessToken);
        String phone = tokenResult.getPhone();
        log.info("手机号码：" + phone);
        ResponseResult<PassengerUser> userByPhone = servicePassengerUserClient.getUserByPhone(phone);
        return ResponseResult.success(userByPhone.getData());

    }
}
